# Contributor: qaqland <qaq@qaq.land>
# Maintainer: qaqland <qaq@qaq.land>
pkgname=dnote
pkgver=0.15.1
pkgrel=0
pkgdesc="A simple command line notebook for programmers (cli)"
url="https://www.getdnote.com/"
arch="all !armhf !armv7 !x86" # no 32 support
license="GPL-3.0-or-later"
makedepends="go"
checkdepends="bash"
options="net"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/dnote/dnote/archive/refs/tags/cli-v$pkgver.tar.gz"
builddir="$srcdir/$pkgname-cli-v$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"
export GOOS=linux
export CGO_ENABLED=1

# upstream's makefile is made for github release, only need build here
build() {
	local ldflags="-X main.apiEndpoint=https://api.getdnote.com \
		-X main.versionTag=$pkgver"
	go build \
		-ldflags "$ldflags" \
		-tags "fts5" \
		-o build/cli \
		./pkg/cli
}

check() {
	make test-cli
}

package() {
	install -Dm755 build/cli "$pkgdir"/usr/bin/dnote

	install -Dm644 README.md LICENSE licenses/GPLv3.txt \
		-t "$pkgdir"/usr/share/doc/dnote/

	install -Dm644 pkg/cli/dnote-completion.bash \
		"$pkgdir"/usr/share/bash-completion/completions/dnote
	install -Dm644 pkg/cli/dnote-completion.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_dnote
}

sha512sums="
b06f82fa40b33d5b59d3308fe1f1def8438a31dd6812ae7ec4fc6ed42ccc7198e03c5e8a12e8db6e635c93e5319d259a7a7f965812939560137f6f195f4c7125  dnote-0.15.1.tar.gz
"
